using System;
using System.IO;
using System.Text;

namespace IceDog.Lib.IO
{
    public static class DhFileReader
    {
        public static void ReadFile(string filename)
        {
            if (!File.Exists(filename))
            {
                return;
            }
            int size = 1200;
            var byteData = new byte[size];
            var charData = new char[size];
            try
            {
                var steam = new FileStream(filename, FileMode.Open);
                steam.Seek(0L, SeekOrigin.Begin);
                steam.Read(byteData, 0, size);
            }
            catch (IOException ex)
            {
                Console.WriteLine("IO exception");
                Console.WriteLine(ex.Message.ToString());
                Console.ReadKey();
                throw;
            }
            var decoder = Encoding.UTF8.GetDecoder();
            var num = decoder.GetChars(byteData, 0, byteData.Length, charData, 0);
            if (num.Equals(size))
            {
                Console.WriteLine(charData);
                Console.ReadKey();
            }
        }
    }
}
